import React, { useState, useEffect } from 'react';
import { Button, Upload } from 'antd';
import { connect } from 'react-redux';
import { headerModules } from '../../../../../utils/utils';

function mapStateToProps(state) {
  return {
    menu: state.menu,
  };
}

function uploadFiles(props) {
  const { menu } = props;
  function handleUploadChange({ file, fileList }) {
    console.log('上传', fileList);
  }
  return (
    <Upload
      name='file'
      accept='.txt'
      action={props.uploadUrl}
      onChange={handleUploadChange}
      headers={{ modules: headerModules(menu.asideHighlight) }}
    >
      <Button>选择文件</Button>
      <p>格式后缀为.txt的文件</p>
    </Upload>
  );
}

function mapStateToProps(state) {
  return {
    menu: state.menu,
  };
}

export default connect(mapStateToProps)(uploadFiles);
